package org.wappumobileapp;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * Tried animated background. Somehow buttons didn't show up. Didn't get this to work. :(
 * 
 * Reference: http://stackoverflow.com/questions/4775650/android-moving-background-image-while-navigating-through-views
 * http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html
 * http://code.google.com/p/android/issues/detail?id=437
 * @author Minna_2
 *
 */
public class MoveBackground extends LinearLayout {
	
	//private Drawable background;     // background picture
	Bitmap background;
	private float x = 0;
	private float y = 0;
	
	public MoveBackground(Context context) {
		super(context);
		background = BitmapFactory.decodeResource(getResources(), R.drawable.background);
        setWillNotDraw(false);
		// TODO Auto-generated constructor stub
	}

	public MoveBackground(Context context, AttributeSet attrs) {
        super(context, attrs);

        //background = context.getResources().getDrawable(R.drawable.background);
        //background.setBounds(0,0,getResources().getDisplayMetrics().widthPixels,getResources().getDisplayMetrics().heightPixels);
        background = BitmapFactory.decodeResource(getResources(), R.drawable.background);
        setWillNotDraw(false);
    }

	
    @Override
    public void onDraw(Canvas canvas) {
    	super.onDraw(canvas);
    	x++;
    	y++;
        canvas.drawBitmap(background, x, y, null);
        // if the view is visible onDraw will be called at some point
     	// in the future
     	
    	//super.onDraw(canvas);    

        // get the object movement

        // Draw background image at its current locations
        //canvas.save();
        //canvas.translate(X,0);
        //background.draw(canvas);
        //canvas.drawBitmap(background, 0, 0, null);
        //canvas.restore();

    	//super.onDraw(canvas);

        // Draw background image at its current locations
        //canvas.save();
        //canvas.translate(x,y);
        //background.draw(canvas);
        //Canvas.drawBitmap(bitmap,srcRect,dstRect,mPaint)
        //canvas.drawBitmap(background, 0, 0, null);
        //canvas.restore();
    }
    
    
	//@Override
	//protected void onDrawBackground(Canvas canvas){
		//int width = this.getWidth();
		//int height = this.getHeight();
		//RectF rect = new RectF(0, 0, width-1, height-1);
		//canvas.drawRoundRect(rect, 6, 6, Background);
		//canvas.drawRoundRect(rect, 6, 6, Line1);
	//	canvas.drawBitmap(background, 0, 0, null);
	//}

}
